package com.example.fengyungo.dao;

import com.example.fengyungo.domain.pojo.OrderDriver;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderDriverDao {

    /**
     * 司机接收订单，等待用户回应
     * @param orderDriver OrderDriver
     * @return Integer
     */
    @Insert("insert into order_driver(number,driverId,status) values(#{number},#{driverId},#{status})")
    Integer addOrderDriver(OrderDriver orderDriver);

    /**
     * 查询愿意接收订单的司机
     * @param number 订单编号
     * @return List<OrderDriver>
     */
    @Select("select * from order_driver where number = #{number} and status = 0")
    List<OrderDriver> getOrderDriverByNumber(String number);

    /**
     * 修改状态
     * @param orderDriver OrderDriver
     * @return Integer
     */
    @Update("update order_driver set status = #{status} where number = #{number} and driverId = #{driverId}")
    Integer updateOrderDriverStatus(OrderDriver orderDriver);

}
